/*
 * Lab2.fx
 *
 * Created on 27.09.2009, 14:41:10
 */

package javafx179labs.gromova.lab2;

/**
 * @author Софья
 */import javafx.stage.Stage;
import javafx.scene.Scene;
import javafx.ext.swing.SwingTextField;
import javafx.ext.swing.SwingButton;
import javafx.scene.input.MouseEvent;
import javafx.scene.Group;
import javafx.scene.text.Font;


var pvivod: Group[] = [];
var W = 70;
var H = 25;
var poleVv: SwingTextField = SwingTextField {
        columns: 30
        layoutX: 150
        editable: true
        font: Font {
            size: 20
            name: "Chiller"
        }
        

    }

var Dbutton: SwingButton = SwingButton {
        text: "Dobavit'"
        width: W*2
        height: H
        layoutX: 1
        font: Font {
            size: 12
            name: "Ravie"
        }
        
        opacity: 0.6
        onMouseClicked: function(e: MouseEvent) {
                insert creator(poleVv.text) into pvivod
                }
    }

function proced (seq: Group[]) {
        var inc = 0; for (e in seq) {
        e.translateY = inc; inc += 30;
        }
        return seq;
        }

function creator(str: String) {
    var field: SwingTextField = SwingTextField {
        columns: 30
        layoutX: 150
        text: str
        editable: false
        font: Font {
            size: 20
            name: "Chiller"
        }
    
    }


    var b1: SwingButton = SwingButton {
        text: "Pravit'"
        width: W
        height: H
        layoutX:1

        onMouseClicked: function(e: MouseEvent) {
                field.editable = not field.editable;
                }
    }


    var b2: SwingButton = SwingButton {
        text: "Udalit'"
        width: W
        height: H
        layoutX: 75
        
        onMouseClicked: function(e: MouseEvent) {
                delete name from pvivod;
                }
    }

      var name: Group = Group {
        content: [field, b1, b2]
    }
return name
}


insert creator("Isprav' menya...") into pvivod;
insert creator("Udali menya...") into pvivod;

Stage {
       scene: Scene {
    width: 500
    height: 500
            content: [
                poleVv,
                Dbutton,
                Group {
                    translateY: 30
                    content: bind [proced(pvivod)]
                }
        ]
    }
}